#include <iostream>
using namespace std;

//if a is a prime return ture, else return false
bool prime(int a){
	if(a <= 1) return false;
	for(int i = 2; i <= a/2 + 1; i++){
		if(a % i == 0){
			return false;
		}
	}
	return true;
}

//return result
int dfs(int (&num)[21], int begin, int end, int (&choose)[21], int count, int countSum){
	if(count <= 0) return 0;
	if(end - begin + 1 < count) return 0;
	if(count == 1){
		choose[count] = num[begin];
		int sum = 0;
		for(int i = 1; i <= countSum ;i++)
			sum += choose[i];
		if(prime(sum)) {
			return 1;
		}
		else {
			return 0;
		}
	}
	choose[count] = num[begin];
	int sum = 0;
	for(int i = begin + 1; i <= end; i++)
		sum += dfs(num, i, end, choose, count - 1, countSum);
	return sum;
}

int main(){
	int n;
	int k;
	cin >> n >> k;
	int num[21];
	int choose[21];
	for(int i = 1; i <= n; i++)
		cin >> num[i];
	int result = 0;
	for(int i = 1; i <= n; i++)
		result += dfs(num, i, n, choose, k, k);
	cout << result << endl;
}
